{extend name="admin@index_layout"/}
{block name="main"}


<div class="layui-card">
    <div class="layui-card-header">护士列表</div>
    <div class="layui-card-body">
        <table class="layui-hide" id="currentTable" lay-filter="currentTable"
               data-auth-add="{:$auth->check('pz.pz/add')}"
               data-auth-edit="{:$auth->check('pz.pz/edit')}"
               data-auth-delete="{:$auth->check('pz.pz/del')}"
        ></table>
    </div>
</div>

<script type="text/html" id="picTpl">

    <img style="max-width:80px; max-height:30px;" src="{{d.img}}" data-image="{{d.name}}">

</script>

<script type="text/html" id="statusTypeTpl">
    <input type="checkbox" name="status" data-href='{:url("setstate")}?id={{d.id}}' value="{{d.id}}" lay-skin="switch"
           lay-text="显示|隐藏" lay-filter="switchStatus" {{ d.status==1 ? 'checked' : '' }}>
</script>


<script type="text/html" id="barTool">

    <a data-open='{:url("commentList")}?id={{ d.id }}'
       class="layui-btn layui-btn-xs layui-btn-warm {:$auth->check('pz.pz/commentList')?'':'layui-hide'}"
       title="护士评价" data-full="true">护士评价</a>

    <a data-open='{:url("edit")}?id={{ d.id }}'
       class="layui-btn layui-btn-xs {:$auth->check('pz.pz/edit')?'':'layui-hide'}"
       title="编辑" data-full="true">编辑</a>

    <a href='{:url("del")}?ids={{ d.id }}'
       class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del">删除</a>
</script>


<!--操作模板-->

{/block}
{block name="script"}
<script>
    var selectElement = null;
    layui.use('yznTable', function () {
        var table = layui.yznTable;
        var init = {
            table_elem: '#currentTable',
            table_render_id: 'currentTable',
            add_url: "{:url('add')}",
            edit_url: "{:url('edit')}",
            delete_url: "{:url('del')}",
        };
        var proviec = {:json_encode($proviec)};
        table.render({
            init: init,
            autoWidth: true,
            toolbar: ['refresh',
                [{
                    text: '添加',
                    url: init.add_url,
                    method: 'open',
                    icon: 'iconfont icon-add',
                    class: 'layui-btn layui-btn-normal layui-btn-sm',
                    extend: 'data-full="true"',
                }],
            ],
            url: '{:url("index")}',
            cols: [
                [
                    //关联会员 护士等级
                    // {type: 'checkbox', fixed: 'left'},
                    {field: 'id', width: '4%', title: 'ID'},
                    {field: 'nickname', align: "center", width: '15%', title: '关联会员',search: false},
                    {field: 'name', align: "center", width: '20%', title: '姓名'},
                    {field: 'img', align: "center", width: '10%', title: '头像', templet: '#picTpl', search: false},
                    {
                        field: 'province',
                        align: "center",
                        width: '15%',
                        title: '省',
                        selectList: proviec
                    },
                    {
                        field: 'city', align: "center", width: '15%', title: '市',
                        selectList: {}
                    },
                    {field: 'phone', align: "center", width: '10%', title: '电话',search: false},
                    {field: 'pz_level_name', align: "center", width: '10%', title: '护士等级',search: false},

                    // {field: 'pz_volume', align: "center", width: '10%', title: '总营业额',search: false},
                    // {field: 'order_num', align: "center", width: '10%', title: '服务次数',search: false},

                    // {field: 'status_time', align: "center", width: '15%', title: '创建时间',search: false},
                    {fixed: 'right', align: "center", width: '20%', title: '操作', toolbar: '#barTool'}//delete'
                ]
            ],
            page: {}
        });
        yznTable.bindevent();
        selectElement = document.getElementById('c-province');
        selectElement.setAttribute("lay-filter", "c-province");
        form1();
        selectElement2 = document.getElementById('searchFieldset_currentTable');
        selectElement2.classList.remove("layui-hide");
        var element = document.getElementById('layui-input-search');
        element.parentNode.removeChild(element);
        console.log(selectElement2);

    });

    function form1() {
        layui.use('form', function () {
            var form = layui.form;
            form.on('select(c-province)', function (data) {
                console.log(data.value);
                $.ajax({
                    type: "POST",//规定传输方式
                    url: "{:url('getc_cate2')}",//提交URL
                    data: {'id': data.value},//提交的数据
                    success: function (result) {
                        if (result.code == 200) {
                            $("#c-city").empty();
                            var str = "<option value>- 全部 -</option>";
                            $.each(result.data, function (i, val) {
                                str += '<option value=' + val.id + '>' + val.name + '</option>'
                            });
                            $("#c-city").append(str);
                            layui.form.render('select');
                        }
                    },
                    error: function () {
                        alert("获取信息失败")
                    }
                });
            })
        });
    }


</script>
{/block}